package entity;

import java.io.File;
import java.util.Date;

public class MyFile {

    private Long file_id;//主键

    private File files;//上传文件
    private String filesFileName;//文件名称
    private String filesContentType;//文件类型
    private String file_path;//服务器文件所在路径
    private Long file_size;//文件大小
    private Date upload_date;//上传时间
    private Integer download_count;//下载次数
    private String is_open;//是否公开 (模型封装)
    private String icon;//图标
    private Extract extract;

    public String getSuffix(){
        return this.getFilesFileName().substring(this.getFilesFileName().lastIndexOf(".")+1);
    }

    public String getIcon() {
        return icon;
    }

    public void setIcon(String icon) {
      this.icon = icon;
    }


    public void setIconBySuffix(String suffix) {

        switch (suffix){
            case "7z": this.icon="img/7z.png";break;
            case "avi": this.icon="img/avi.png";break;
            case "css": this.icon="img/css.png";break;
            case "csv": this.icon="img/csv.png";break;
            case "doc": this.icon="img/doc.png";break;
            case "docx": this.icon="img/doc.png";break;
            case "eml": this.icon="img/eml.png";break;
            case "eps": this.icon="img/eps.png";break;
            case "html": this.icon="img/html.png";break;
            case "htm": this.icon="img/html.png";break;
            case "jpg": this.icon="img/jpg.png";break;
            case "mov": this.icon="img/mov.png";break;
            case "mp3": this.icon="img/mp3.png";break;
            case "mp4": this.icon="img/mp4.png";break;
            case "mpp": this.icon="img/mpp.png";break;
            case "pdf": this.icon="img/pdf.png";break;
            case "png": this.icon="img/png.png";break;
            case "ppt": this.icon="img/ppt.png";break;
            case "pptx": this.icon="img/pptx.png";break;
            case "pub": this.icon="img/pub.png";break;
            case "rar": this.icon="img/rar.png";break;
            case "raw": this.icon="img/raw.png";break;
            case "rtf": this.icon="img/rtf.png";break;
            case "ttf": this.icon="img/ttf.png";break;
            case "txt": this.icon="img/txt.png";break;
            case "vsdx": this.icon="img/vsdx.png";break;
            case "wav": this.icon="img/wav.png";break;
            case "xls": this.icon="img/xls.png";break;
            case "xlsx": this.icon="img/xlsx.png";break;
            case "zip": this.icon="img/zip.png";break;
            case "apk": this.icon="img/apk.png";break;
            case "jar": this.icon="img/jar.png";break;
            case "midi": this.icon="img/midi.png";break;

            default: this.icon="img/null.png";break;//
        }
    }

    public Extract getExtract() {
        return extract;
    }

    public void setExtract(Extract extract) {
        this.extract = extract;
    }

    public Long getFile_id() {
        return file_id;
    }

    public void setFile_id(Long file_id) {
        this.file_id = file_id;
    }

    public File getFiles() {
        return files;
    }

    public void setFiles(File files) {
        this.files = files;
    }

    public String getFilesFileName() {
        return filesFileName;
    }

    public void setFilesFileName(String filesFileName) {
        this.filesFileName = filesFileName;
    }

    public String getFilesContentType() {
        return filesContentType;
    }

    public void setFilesContentType(String filesContentType) {
        this.filesContentType = filesContentType;
    }

    public String getFile_path() {
        return file_path;
    }

    public void setFile_path(String file_path) {
        this.file_path = file_path;
    }

    public Long getFile_size() {
        return file_size;
    }

    public void setFile_size(Long file_size) {
        this.file_size = file_size;
    }

    public Date getUpload_date() {
        return upload_date;
    }

    public void setUpload_date(Date upload_date) {
        this.upload_date = upload_date;
    }


    public Integer getDownload_count() {
        return download_count;
    }

    public void setDownload_count(Integer download_count) {
        this.download_count = download_count;
    }

    public String getIs_open() {
        return is_open;
    }

    public void setIs_open(String is_open) {
        this.is_open = is_open;
    }

    @Override
    public String toString() {
        return "MyFile{" +
                "file_id=" + file_id +
                ", files=" + files +
                ", filesFileName='" + filesFileName + '\'' +
                ", filesContentType='" + filesContentType + '\'' +
                ", file_path='" + file_path + '\'' +
                ", file_size=" + file_size +
                ", upload_date=" + upload_date +
                ", download_count=" + download_count +
                ", is_open='" + is_open + '\'' +
                ", icon='" + icon + '\'' +
                '}';
    }
}
